package com.shop2cn.iapi.member.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.member.parameter.MchSetBindTypeBean;
import com.shop2cn.iapi.member.service.MchSetBindTypeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmember.MchMemberConfig;
import com.ymttest.database.sqlwapper.godmember.GodMemberWapper;
/**
*商家设置绑定关系
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_MchSetBindType{
	private static MchSetBindTypeBean mchsetbindtypeBean;
	private static MchSetBindTypeCall mchsetbindtypeCall;
	GodMemberWapper GodMemberWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商家设置绑定关系");
	}

	@Before
	public void caseUp() {
		mchsetbindtypeBean=new MchSetBindTypeBean();
		mchsetbindtypeCall=new MchSetBindTypeCall();
		GodMemberWapper=new GodMemberWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(mchsetbindtypeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_MchSetBindType_001() {
		Logger.start(true,"商家设置绑定关系成功bindType1");
		try {
			Integer shopid= GodmchManageCallService.CreateSellerMch();
			mchsetbindtypeBean.setBindType(1);
			mchsetbindtypeBean.setShopId(shopid);
			mchsetbindtypeCall.setData(mchsetbindtypeBean);
			mchsetbindtypeCall.callService();			
			Logger.verifyEquals("200", mchsetbindtypeCall.getString("code"), "验证code");
			Logger.verifyEquals("true", mchsetbindtypeCall.getString("data"), "验证data");
			MchMemberConfig db = GodMemberWapper.selectMchMemberConfigByShopId(mchsetbindtypeBean.getShopId());
			Logger.verifyEquals(mchsetbindtypeBean.getBindType(), db.getBindType(), "验证getCollectionMobile");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_MchSetBindType_002() {
		Logger.start(true,"不输入shopId失败");
		try {
			Integer shopid= GodmchManageCallService.CreateSellerMch();
			mchsetbindtypeBean.setBindType(1);
//			mchsetbindtypeBean.setShopId(shopid);
			mchsetbindtypeCall.setData(mchsetbindtypeBean);
			mchsetbindtypeCall.callService();			
			Logger.verifyEquals("400", mchsetbindtypeCall.getString("code"), "验证code");
	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	public void Tc_MchSetBindType_003() {
		Logger.start(true,"不输入bindType失败");
		try {
			Integer shopid= GodmchManageCallService.CreateSellerMch();
//			mchsetbindtypeBean.setBindType(1);
			mchsetbindtypeBean.setShopId(shopid);
			mchsetbindtypeCall.setData(mchsetbindtypeBean);
			mchsetbindtypeCall.callService();			
			Logger.verifyEquals("400", mchsetbindtypeCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_MchSetBindType_004() {
		Logger.start(true,"商家设置绑定关系成功bindType0");
		try {
			Integer shopid= GodmchManageCallService.CreateSellerMch();
			mchsetbindtypeBean.setBindType(0);
			mchsetbindtypeBean.setShopId(shopid);
			mchsetbindtypeCall.setData(mchsetbindtypeBean);
			mchsetbindtypeCall.callService();			
			Logger.verifyEquals("200", mchsetbindtypeCall.getString("code"), "验证code");
			Logger.verifyEquals("true", mchsetbindtypeCall.getString("data"), "验证data");
			MchMemberConfig db = GodMemberWapper.selectMchMemberConfigByShopId(mchsetbindtypeBean.getShopId());
			Logger.verifyEquals(mchsetbindtypeBean.getBindType(), db.getBindType(), "验证getCollectionMobile");
	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}